#ifndef PARSER_HH_
# define PARSER_HH_

#include <istream>
#include <list>
#include <vector>
#include <sstream>
#include <map>
#include <set>

#include "cv.h"
#include "highgui.h"
#include "operations.hh"

typedef IplImage t_variable;
typedef CvCapture t_input_var;

typedef CvVideoWriter t_output_var;

typedef std::map<std::string, t_variable*> t_variables_map;
typedef std::map<std::string, t_input_var*> t_input_vars_map;
typedef std::map<std::string, t_output_var*> t_output_vars_map;

typedef struct t_stage_
{
  std::string operation;
  std::string ret;
  std::vector<std::string> args;

  void parse(std::istream& in,
	     t_variables_map& variables,
	     t_input_vars_map& input_variables,
	     t_output_vars_map& output_variables);

  std::string to_string() const;

} t_stage;

typedef struct t_toolchain_
{
  std::list<t_stage> stages;

  t_input_vars_map input_variables;

  t_output_vars_map output_variables;

  t_variables_map variables;

  void parse(std::istream& in);

  std::string to_string() const;

} t_toolchain;

#endif
